<template>
	<view class="main">
		<view class="box">
			<uni-easyinput autoHeight v-model="value" v-if="isteztarea" type="textarea" :placeholder="$t('mine.infoPlaceholder')"></uni-easyinput>
			<view class="name" v-else>
				<text>{{$t('mine.nikeName')}}:</text> <uni-easyinput class="ipt" v-model="nikename" :placeholder="$t('mine.nikeNamePlaceholder')"></uni-easyinput>
			</view>
		</view>
		<view class="btn" @click="submit">
			{{$t('index.submit')}}
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				value:"",
				nikename:"",
				isteztarea:false
			};
		},
		onLoad(options){
			this.isteztarea = options.val == "duction"? true:false
			this.value = options.description
			this.nikename = options.description
		},
		methods:{
			submit(){
				let token = JSON.parse(uni.getStorageSync('token')).token
				let params = {
					 ustoken:token
				}
				if(this.isteztarea){
					params.desc = this.value
				}else{
					params.firstname = this.nikename
				}
				this.$httpRequest({
					url:"app/api/updateselfInfo.php",
					method:"POST",
					data:params
				}).then(res=>{
					if(res.errorcode == 200){
						uni.showToast({
							title:"修改成功",
							icon:"success"
						})
						setTimeout(()=>{
							uni.navigateBack({
								delta:1
							})
						},1500)
					
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
.main{
	width: 100%;
	margin: 20rpx auto;
	.box{
		width: 90%;
		margin: 20rpx auto 0;
		::v-deep .uni-easyinput__content{
			border: none;
		}
		.name{
			display: flex;
			justify-content: space-around;
			align-items: center;
			text{
				margin-right: 10rpx;
			}
			.ipt{
				flex: 1;
			}
		}
	}
	.btn {
		width: 90%;
		margin: 48rpx auto 0;
		text-align: center;
		line-height: 94rpx;
		color: #FFFFFF;
		font-size: 32rpx;
		font-weight: 500;
		border-radius: 144rpx;
		background: #4DBEC1;
	}
}
</style>
